'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.ua = exports.isAndroid = exports.isIos = undefined;

var _uaParser = require('./ua-parser');

var _uaParser2 = _interopRequireDefault(_uaParser);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var userAgent = navigator.userAgent;

var regIphone = /\b(iphone|ipad)\b/i;

var isIos = exports.isIos = function isIos() {
    return regIphone.test(userAgent);
};

var regAndroid = /\bandroid\b/i;
var isAndroid = exports.isAndroid = function isAndroid() {
    return regAndroid.test(userAgent);
};

var _UAParser$OS = _uaParser2.default.OS,
    NAME = _UAParser$OS.NAME,
    VERSION = _UAParser$OS.VERSION,
    _UAParser$DEVICE = _uaParser2.default.DEVICE,
    MODEL = _UAParser$DEVICE.MODEL,
    VENDOR = _UAParser$DEVICE.VENDOR,
    TYPE = _UAParser$DEVICE.TYPE,
    MOBILE = _UAParser$DEVICE.MOBILE,
    TABLET = _UAParser$DEVICE.TABLET;

var regs = {
    browser: [[/((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i], [[NAME, 'UCBrowser'], VERSION], [/(micromessenger)\/([\w\.]+)/i], [[NAME, 'WeChat'], VERSION], [/(qqbrowserlite)\/([\w\.]+)/i], [NAME, VERSION], [/(QQ)\/([\d\.]+)/i], [NAME, VERSION], [/m?(qqbrowser)[\/\s]?([\w\.]+)/i], [NAME, VERSION], [/(BIDUBrowser)[\/\s]?([\w\.]+)/i], [NAME, VERSION], [/(2345Explorer)[\/\s]?([\w\.]+)/i], [NAME, VERSION], [/(MetaSr)[\/\s]?([\w\.]+)/i], [NAME], [/(LBBROWSER)/i], [NAME], [/xiaomi\/miuibrowser\/([\w\.]+)/i], [VERSION, [NAME, 'MIUI Browser']], [/\swv\).+(chrome)\/([\w\.]+)/i], [[NAME, /(.+)/, '$1 WebView'], VERSION], [/((?:oculus|samsung)browser)\/([\w\.]+)/i], [[NAME, /(.+(?:g|us))(.+)/, '$1 $2'], VERSION], [/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i], [VERSION, [NAME, 'Android Browser']], [/((?:android.+)crmo|crios)\/([\w\.]+)/i], [[NAME, 'Chrome'], VERSION], [/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i], [VERSION, [NAME, 'Mobile Safari']], [/version\/([\w\.]+).+?(mobile\s?safari|safari)/i], [VERSION, NAME]],
    device: [[/\((ip[honed|\s\w*]+);.+(apple)/i], [MODEL, VENDOR, [TYPE, MOBILE]], [/\((ip[honed|\s\w*]+);/i], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [/d\/huawei([\w\s-]+)[;\)]/i, /(nexus\s6p)/i], [MODEL, [VENDOR, 'Huawei'], [TYPE, MOBILE]], [/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i, /((SM-T\w+))/i], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [/android.+;\s(oppo)\s?([\w\s]+)\sbuild/i], [VENDOR, MODEL, [TYPE, MOBILE]], [/android.+;\s(\w+)\s+build\/hm\1/i, /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, /android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i, /android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [/android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, TABLET]], [/android.+;\s(m[1-5]\snote)\sbuild/i], [MODEL, [VENDOR, 'Meizu'], [TYPE, TABLET]], [/android.+a000(1)\s+build/i, /android.+oneplus\s(a\d{4})\s+build/i], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [/(android[\w\.\s\-]{0,9});.+build/i], [MODEL, [VENDOR, 'Generic']]],
    os: [[/ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i], [[VERSION, /_/g, '.'], [NAME, 'ios']], [/android[\/\s-]?([\w\.]*)/i], [[NAME, 'android'], VERSION]]
};

var ua = exports.ua = new _uaParser2.default(userAgent, regs);